
#include "n32g45x.h"

#define RUN_LED_PORT    GPIOB
#define RUN_LED_PIN     GPIO_PIN_5

int driv_run_led_init(void)
{
    return 0;
}

int driv_run_led_op(int on_off)
{
    if (on_off > 0) {
        // led on
        GPIO_WriteBit(RUN_LED_PORT, RUN_LED_PIN, Bit_SET);
    } else if (on_off == 0) {
        // led off
        GPIO_WriteBit(RUN_LED_PORT, RUN_LED_PIN, Bit_SET);
    } else {
        // led toggle
        if (GPIO_ReadOutputDataBit(RUN_LED_PORT, RUN_LED_PIN) == Bit_SET)
        {
            GPIO_WriteBit(RUN_LED_PORT, RUN_LED_PIN, Bit_RESET);
        } else {
            GPIO_WriteBit(RUN_LED_PORT, RUN_LED_PIN, Bit_SET);
        }
    }
    return 0;
}
